using System;
using System.Collections.Generic;
using System.Text;
using Rapier.Kodachi.Shared;
using System.Drawing;
using System.IO;
using Rapier.Kodachi.WinForm;

namespace Rapier.Kodachi.Actions
{
    public class ShowOptions : Action
    {
        public ShowOptions()
            : base(null, "Internal", "Options", "Launch Kodachi Options Dialog")
        {
            string fileName = Path.GetTempFileName();
            fileName += ".ini";
            using (StreamWriter writer = File.CreateText(fileName)) { }

            int imageIndex = Global.SystemImageList.IconIndex(fileName, true, ShellIconStateConstants.ShellIconStateNormal);
            Icon icon = Global.SystemImageList.Icon(imageIndex);
            if (icon != null)
                GetImage = delegate() { return icon.ToBitmap(); };
            
            File.Delete(fileName);
        }

        public override bool IsValidDirect(Item directItem)
        {
            return directItem.Properties.ContainsKey("Kodachi") && directItem.Properties["Kodachi"].Equals(true);
        }

        public override void Execute(Item[] directItems, Item[] indirectItems)
        {
            WindowMain.controller.ShowOptions();
        }
    }
}
